#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H

#include <QDialog>
#include <QLineEdit>
#include <QSpinBox>
#include <QCheckBox>
#include <QPushButton>
#include <QGroupBox>
#include <QVBoxLayout>
#include <QFormLayout>
#include <QDialogButtonBox>

class SettingsDialog : public QDialog
{
    Q_OBJECT

public:
    explicit SettingsDialog(QWidget *parent = nullptr);
    ~SettingsDialog();

    // Getter methods for all configuration values
    int checkInterval() const;
    int highFreqThreshold() const;
    int lowFreqThreshold() const;
    int sustainedPeriodHigh() const;
    int sustainedPeriodLow() const;
    int freqReduction() const;
    int freqIncrease() const;
    int targetFreqAfterReduction() const;
    int ioCriticalThreshold() const;
    int ioSevereThreshold() const;
    int ioHighThreshold() const;
    QString logFile() const;
    int maxLogSizeMB() const;
    int maxLogFiles() const;

    // Setter methods for all configuration values
    void setCheckInterval(int value);
    void setHighFreqThreshold(int value);
    void setLowFreqThreshold(int value);
    void setSustainedPeriodHigh(int value);
    void setSustainedPeriodLow(int value);
    void setFreqReduction(int value);
    void setFreqIncrease(int value);
    void setTargetFreqAfterReduction(int value);
    void setIoCriticalThreshold(int value);
    void setIoSevereThreshold(int value);
    void setIoHighThreshold(int value);
    void setLogFile(const QString &value);
    void setMaxLogSizeMB(int value);
    void setMaxLogFiles(int value);

private:
    void setupUI();
    void loadSettings();
    void saveSettings();

private slots:
    void accept() override;
    void applySettings();

private:
    // Monitoring settings
    QSpinBox *checkIntervalSpinBox;
    QSpinBox *highFreqThresholdSpinBox;
    QSpinBox *lowFreqThresholdSpinBox;
    QSpinBox *sustainedPeriodHighSpinBox;
    QSpinBox *sustainedPeriodLowSpinBox;

    // Frequency adjustment settings
    QSpinBox *freqReductionSpinBox;
    QSpinBox *freqIncreaseSpinBox;
    QSpinBox *targetFreqAfterReductionSpinBox;

    // IO load threshold settings
    QSpinBox *ioCriticalThresholdSpinBox;
    QSpinBox *ioSevereThresholdSpinBox;
    QSpinBox *ioHighThresholdSpinBox;

    // Log settings
    QLineEdit *logFileLineEdit;
    QSpinBox *maxLogSizeMBSpinBox;
    QSpinBox *maxLogFilesSpinBox;

    QPushButton *applyButton;
    QDialogButtonBox *buttonBox;
};

#endif // SETTINGSDIALOG_H